function printLabel(labelObj:LabelObj){
    console.log(labelObj.label)
}
//接口，interface
// printLabel({})
// interface LabelObj{
//     label:string;
// }
//可选属性?代表可选属性
interface LabelObj{
    label?:string;
    size?:number
}
let obj:LabelObj = {size:12456}
printLabel(obj)

//只读属性,只可读取，对值进行初始化，但不可以修改值
interface Point{
    readonly x:number;
    readonly y:number
}
let point:Point= {x:1,y:3}
// point.x = 123
//函数
interface Fun{
    readonly x:number;
    readonly y:number;
    myFunction:(param:string)=>boolean;
}
let fun:Fun = {x:1,y:2,myFunction:function(param:string){
    return  true;
}}
fun.myFunction("123")
//可索引的类型
interface StringArray{
    [key:number]:string;
    [str:string]:string;
}

let arraystr1:StringArray = {
    0:"zero",
    1:"one",
    name:"test",
    age:"12312"
}
console.log(arraystr1[0])
console.log(arraystr1.name)
//第一在接口定义的时候，我们的规则是：变量名:类型;,赋值的时候，变量名:类型赋值每个属性用,

//实现implements,接口怎么定义的内容，我们的实现类就要怎么定义
interface ClockInterface{
    currentTime:Date;
    setTime(d:Date):Date;
}
class Clock implements ClockInterface{
    date:Date;
    setTime(d: Date) {
       this.date = d;
       return new Date();
    }
    currentTime: Date
}
//继承
interface Shape{
    color:string;
}
interface Test extends Shape{
    test:string
}
//继承，实现都可以同时存在
class Demo extends Clock implements Test{
    test: string;
    color: string;
}



